<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title></title>
	<meta name="viewport"
        content="width=device-width, initial-scale=1">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/amazeui.css">
	<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>public/assets/css/bootstrap.min.css">
	<style type="text/css">

		table{
			width: 100%;
			height: 527;
		}
		th {
			width: 12.5%;
			background-color: rgb(217,237,247);
			color: #fff;
			height: 30px;
			border: 1px solid #ccc;
			text-align: center;
		}
		.content td{
			border: 1px solid #000;
			/*height: 120px;*/
		}
		div{
		   overflow: hidden;
		   text-overflow: ellipsis;
		   width: 95%;
		   height: 109px;
		   margin: 3px;
			   
		}
		
	</style>
</head>

<!--

	我们把课表放入一个一维数组中
	定义一个二维数组 8行7列,i代表行,j代表列
	星期	一	二	三	四	五	六	日
		  j=0   1   2   3   4   5   6
	i=0 	0	1   2   3   4   5   6   
	i=1 	7	8   9   10  11  12  13 
	i=2 	14	15  16  17  18  19  20 
	
	当前这个索引应该是 i*7+j
	然后把这个索引放入二维数组对应的组
	for($i=0 ; $i<8; $i++)
	{
		<tr>
			for( $j=0 ; $j<7; $j++){
				<td>$array[ (i-1)*7+j ]</td>
			}
		</tr>
	}
-->
<!--<?php var_dump($student_info);?>-->
<!--<?php var_dump($course_info[0]);?>-->
<?php
	header("Content-type:text/html;charset=utf-8");
	$new_array =array();
	foreach ($course_info as $val) {
		if($val == "&nbsp;"){
			$val=preg_replace("/&nbsp;/i", "", $val);
		}else{
			$val=preg_replace("/\(.*?\)/i", "", $val);
			
		}
		array_push($new_array, $val);
	}
	$result = array_unique($new_array);
	$result = array_values($result);

?>

<body>
	<table >
		<tr class="header">
			<th></th>
			<th>一</th>
			<th>二</th>
			<th>三</th>
			<th>四</th>
			<th>五</th>
			<th>六</th>
			<th>日</th>
		</tr>

		<?php 
			
                  $time = array('1-2',
                                '3-4',
                                '5-6',
                                '7-8',
                                '9-10',
                                '11-12',
                                '13-14',
                                '15-16');
                  for ($i=0; $i < 8; $i++)
                  {
                    echo "<tr class = 'content'>";
                    echo "<td >".$time[$i]."</td>";
                    for ($j=0; $j < 7; $j++) 
                    { 
                        if(empty($new_array[$i*7+$j]))
                        {
                          echo "<td style='height:110px;'><div ></div></td>";
                        }
                        else{
                        	$key = array_search($new_array[$i*7+$j], $result);
	                        echo "<td style='height:110px;'><a tabindex='0' role='button'  data-toggle='popover'data-placement='bottom' style='text-decoration: none;color:#fff;border:none;' data-trigger='focus' data-content='".$course_info[$i*7+$j]."'><div  class ='class".$key."'>".$course_info[$i*7+$j]."</div></a></td>";
	                    }

                    }
                    echo "</tr>";
                  } 
            ?>
		
		
		

	</table>


</body>

<script type="text/javascript" src="<?php echo base_url()?>public/assets/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>public/assets/js/bootstrap.min.js"></script>

<script type="text/javascript">
	$(function () {
	  $('[data-toggle="popover"]').popover()
	});
	$(document).ready(function(){

		for (var i = 0; i < 14; i++) {
			//length = $("div[class^='class"+i+"']").size();
			$("div[class^='class"+i+"']").css({
				"background-color":getColor(i),
				"border-radius":'5px 5px',
				'border':'0px',
				"color":'#fff'
			});
			
			
		}
	});
	function getColor(i) 
	{ 
		switch(i)
		{
			case 0:
				c = '#3760CD';
				break;
			case 1:
				c = '#FF6461';
				break;
			case 2:
				c = '#F8D880';
				break;
			case 3:
				c = '#EBC6B1';
				break;
			case 4:
				c = '#7F97A3';
				break;
			case 5:
				c = '#E87C3C';
				break;	
			case 6:
				c = '#D2BE53';
				break;
			case 7:
				c = '#C4C6E1';
				break;
			case 8:
				c = '#BDD7BB';
				break;
			case 9:
				c = '#6ACD5F';
				break;
			case 10:
				c = '#6E8EC3';
				break;
			case 11:
				c = '#0D3A3A';
				break;
			case 12:
				c = '#BAACBB';
				break;
			case 13:
				c = '#343F3F';
				break;
			default:
				c = '#00FCFF';
		}

		return c; 
	} 
	</script>
</html>